< previous page page_715 next page >

Page 715
x.Amount = "$20.00"
x.DepositMoney
In these lines of code, x represents an instance of an ActiveX component that handles bank account functions. The last line is a method call to DepositMoney, which presumably requires the other account information to work. This code depends on repeated access to the same object. Another way to write this, in which all of the information is passed to the object, is as follows:
x.DepositMoney(123456,"Stephanie and Brent","$20.00")
Of course, this example is very simple, but think about a more complex example where you were repeatedly calling functions on the object. In the first example, you would have to have access to the same instance of the object x, but in the second example it does not matter. Although the second example looks like more work, if you can write code that is state-independent, you can use tools like Microsoft Transaction Server to pool object connections and create a very "scalable" application.
Using an HTML Template WebItem
To learn how HTML templates work with a WebClass, first create the following simple HTML template, TEST.HTM:
<HTML>
<BODY>
<H1> This is a test page </H1>
<BR>
<A HREF=http://www.somewhere.com> Link to somewhere! </A>

<IMG SRC=guestbook.gif>

</BODY>
</HTML>
There is nothing special about TEST.HTM, until you import it into the project. To do this, open the Designer window for WebClass1, right-click WebClass1, and choose Add HTML Template. Select TEST.HTM from the File dialog box. Your Designer window should now look like the one in Figure 31.11.
note.gif It is a good idea to import an HTML template from outside the project directory, because Visual Basic will automatically save a copy of the template (with subsequent changes) in the project directory. square.gif

After importing an HTML file, it becomes a WebItem.
Creating a Template Event
In the right pane of the Designer window, you see a list of all the HTML tags in the template file that can be connected to Visual Basic events. The new WebItem itself is also given a name, Template1.

 
< previous page page_715 next page >